/*
 * @Author: yangzonglong
 * @Date: 2021-05-12 16:11:38
 * @version: v1.0.0
 * @Descripttion: 编辑工作流
 * @LastEditors: yangzonglong
 * @LastEditTime: 2021-07-28 16:35:40
 * @Auditor: 
 */
import React, { useEffect, useState } from 'react';
import { PageHeader } from '@library';
import Qs from 'query-string';
import { WorkFlowHeadProps } from './../../../../interface';
import { getWorkflow } from './../../Api';

import WfEditor from '@/components/wfEditor/WfEditor';

const WorkflowPage =  () => {
  const query = Qs.parseUrl(window.location.href).query;
  const [workflow, setWorkflow] = useState<WorkFlowHeadProps>({} as any);

  useEffect(() => {
    getWorkflow(query.id as string).then(result => {
      if (result) setWorkflow(result);
    })
  }, [query.id]);

  return (
    <>
      <PageHeader />
      <WfEditor workflowId={workflow.id} bpmnContent={workflow.bpmnContent} />
    </>
  )
}

export default WorkflowPage